// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   NameRenderer.java

package com.boci.common.ui.control;

import com.boci.clientapp.main.ClientAppLoader;
import com.boci.common.constant.ClientAppConst;
import java.awt.Color;
import java.awt.Component;
import java.util.Locale;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.table.TableCellRenderer;

public class NameRenderer extends JLabel
    implements TableCellRenderer
{

    public NameRenderer(Locale pLocale)
    {
        setBorder(new EmptyBorder(0, 2, 0, 2));
        currentLocale = pLocale;
    }

    public void setText(Locale pLocale)
    {
        currentLocale = pLocale;
        setFont(ClientAppLoader.getSmallPlainTextFont(pLocale));
    }

    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
    {
        strNames = (String[])(String[])value;
        try
        {
            String strName;
            if(currentLocale.equals(ClientAppConst.ZH_CN) && strNames[2] != null && strNames[2].length() != 0)
                strName = strNames[2];
            else
            if(currentLocale.equals(ClientAppConst.ZH_HK) && strNames[1] != null && strNames[1].length() != 0)
                strName = strNames[1];
            else
                strName = strNames[0];
            setToolTipText(strName);
            setText(strName);
            setOpaque(true);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        if(row % 2 == 0)
        {
            setBackground(new Color(255, 255, 200));
            setForeground(table.getForeground());
        } else
        {
            setBackground(Color.WHITE);
            setForeground(table.getForeground());
        }
        return this;
    }

    private String strNames[];
    private Locale currentLocale;
}
